#include <catch2/catch.hpp>

#include <cmath>

#include "solution.hpp"

using namespace solution_039;

TEST_CASE("39. Combination Sum", "[039]") {

SECTION("example 1") {
    std::vector candidates{2,3,6,7};
    SECTION("version 1") { CHECK(Solution().combinationSum(candidates, 7)  == std::vector<std::vector<int>>{{2,2,3},{7}}); }
    SECTION("version 2") { CHECK(Solution().combinationSum2(candidates, 7) == std::vector<std::vector<int>>{{2,2,3},{7}}); }
    SECTION("version 3") { CHECK(Solution().combinationSum3(candidates, 7) == std::vector<std::vector<int>>{{2,2,3},{7}}); }
}

SECTION("example 2") {
    std::vector candidates{2,3,5};
    SECTION("version 1") { CHECK(Solution().combinationSum(candidates, 8)  == std::vector<std::vector<int>>{{2,2,2,2},{2,3,3},{3,5}}); }
    SECTION("version 2") { CHECK(Solution().combinationSum2(candidates, 8) == std::vector<std::vector<int>>{{2,2,2,2},{2,3,3},{3,5}}); }
    SECTION("version 3") { CHECK(Solution().combinationSum3(candidates, 8) == std::vector<std::vector<int>>{{2,2,2,2},{2,3,3},{3,5}}); }
}

SECTION("example 3") {
    std::vector candidates{2};
    SECTION("version 1") { CHECK(Solution().combinationSum(candidates, 1)  == std::vector<std::vector<int>>{}); }
    SECTION("version 2") { CHECK(Solution().combinationSum2(candidates, 1) == std::vector<std::vector<int>>{}); }
    SECTION("version 3") { CHECK(Solution().combinationSum3(candidates, 1) == std::vector<std::vector<int>>{}); }
}

SECTION("example 4") {
    std::vector candidates{1};
    SECTION("version 1") { CHECK(Solution().combinationSum(candidates, 1)  == std::vector<std::vector<int>>{{1}}); }
    SECTION("version 2") { CHECK(Solution().combinationSum2(candidates, 1) == std::vector<std::vector<int>>{{1}}); }
    SECTION("version 3") { CHECK(Solution().combinationSum3(candidates, 1) == std::vector<std::vector<int>>{{1}}); }
}

SECTION("example 5") {
    std::vector candidates{1};
    SECTION("version 1") { CHECK(Solution().combinationSum(candidates, 2)  == std::vector<std::vector<int>>{{1,1}}); }
    SECTION("version 2") { CHECK(Solution().combinationSum2(candidates, 2) == std::vector<std::vector<int>>{{1,1}}); }
    SECTION("version 3") { CHECK(Solution().combinationSum3(candidates, 2) == std::vector<std::vector<int>>{{1,1}}); }
}

}
